Brandy Austin - API Muncher - Octos#42
Open
brandyaustinseattle wants to merge 21 commits intoAda-C9:masterfrom
Open
Brandy Austin - API Muncher - Octos#42brandyaustinseattle wants to merge 21 commits intoAda-C9:masterfrom
brandyaustinseattle wants to merge 21 commits intoAda-C9:masterfrom
Conversation
API MuncherWhat We're Looking For
|
droberts-sea
reviewed
May 7, 2018
|
|
||
| get '/recipes', to: 'recipes#index', as: :index | ||
| get '/search', to: 'recipes#search', as: :search | ||
|
|
| recipe = MuncherApiWrapper.show_recipe(id) | ||
|
|
||
| if recipe.nil? | ||
| flash[:notice] = "Something went wrong. Please enter a new search." |
There was a problem hiding this comment.
This is where using an exception to report errors comes in handy - an exception contains a lot more useful info than a nil.
| # #recipe_ always has to be last # delimited item in uri otherwise this breaks | ||
| label_uri_image[:id] = r["recipe"]["uri"].split("#recipe_")[-1] | ||
| label_uri_image[:image] = r["recipe"]["image"] | ||
|
|
There was a problem hiding this comment.
Good work sorting out the recipe URI!
| label_uri_image = {} | ||
| label_uri_image[:label] = r["recipe"]["label"] | ||
| # #recipe_ always has to be last # delimited item in uri otherwise this breaks | ||
| label_uri_image[:id] = r["recipe"]["uri"].split("#recipe_")[-1] |
There was a problem hiding this comment.
You should be creating an instance of your Recipe class here. That would let the controller / views treat this like any other model, and isolate the knowledge of how the API sends data back in one place.
| it "can't get the recipe's info and redirects with invalid id" do | ||
| VCR.use_cassette("chicken") do | ||
| recipe_list = MuncherApiWrapper.list_recipes("chicken") | ||
| id = recipe_list.first[:id] + "abc" |
There was a problem hiding this comment.
Good work nailing this error case. It might also be worthwhile to add some tests around the paging parameters:
- What happens if they're absent?
- Do you get different results when they change?
- What if you send a bogus value, like a negative page number?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
API Muncher
Congratulations! You're submitting your assignment!
Comprehension Questions